<?php

namespace JLPay\Models\Marketing;

use JLPay\Models\BaseResponse;

/**
 * 商户活动配置数据
 */
class MerchantActivityConfigData
{
    /**
     * 活动ID
     * @var string|null
     */
    public ?string $actId = null;

    /**
     * 商户号
     * @var string|null
     */
    public ?string $merchNo = null;

    /**
     * 终端号列表
     * @var array|null
     */
    public ?array $termNos = null;

    /**
     * 开始时间
     * @var string|null
     */
    public ?string $startTime = null;

    /**
     * 结束时间
     * @var string|null
     */
    public ?string $endTime = null;

    /**
     * 状态
     * @var string|null
     */
    public ?string $status = null;

    /**
     * 创建时间
     * @var string|null
     */
    public ?string $createTime = null;

    /**
     * 更新时间
     * @var string|null
     */
    public ?string $updateTime = null;

    /**
     * 设置活动ID
     *
     * @param string $actId 活动ID
     * @return $this
     */
    public function setActId(string $actId): self
    {
        $this->actId = $actId;
        return $this;
    }

    /**
     * 设置商户号
     *
     * @param string $merchNo 商户号
     * @return $this
     */
    public function setMerchNo(string $merchNo): self
    {
        $this->merchNo = $merchNo;
        return $this;
    }

    /**
     * 设置终端号列表
     *
     * @param array $termNos 终端号列表
     * @return $this
     */
    public function setTermNos(array $termNos): self
    {
        $this->termNos = $termNos;
        return $this;
    }

    /**
     * 设置开始时间
     *
     * @param string $startTime 开始时间
     * @return $this
     */
    public function setStartTime(string $startTime): self
    {
        $this->startTime = $startTime;
        return $this;
    }

    /**
     * 设置结束时间
     *
     * @param string $endTime 结束时间
     * @return $this
     */
    public function setEndTime(string $endTime): self
    {
        $this->endTime = $endTime;
        return $this;
    }

    /**
     * 设置状态
     *
     * @param string $status 状态
     * @return $this
     */
    public function setStatus(string $status): self
    {
        $this->status = $status;
        return $this;
    }

    /**
     * 设置创建时间
     *
     * @param string $createTime 创建时间
     * @return $this
     */
    public function setCreateTime(string $createTime): self
    {
        $this->createTime = $createTime;
        return $this;
    }

    /**
     * 设置更新时间
     *
     * @param string $updateTime 更新时间
     * @return $this
     */
    public function setUpdateTime(string $updateTime): self
    {
        $this->updateTime = $updateTime;
        return $this;
    }

    /**
     * 将对象转换为数组
     *
     * @return array
     */
    public function toArray(): array
    {
        $result = [];
        if ($this->actId !== null) $result['act_id'] = $this->actId;
        if ($this->merchNo !== null) $result['merch_no'] = $this->merchNo;
        if ($this->termNos !== null) $result['term_nos'] = $this->termNos;
        if ($this->startTime !== null) $result['start_time'] = $this->startTime;
        if ($this->endTime !== null) $result['end_time'] = $this->endTime;
        if ($this->status !== null) $result['status'] = $this->status;
        if ($this->createTime !== null) $result['create_time'] = $this->createTime;
        if ($this->updateTime !== null) $result['update_time'] = $this->updateTime;
        return $result;
    }
}

/**
 * 商户活动配置查询响应模型
 */
class MerchantActivityConfigQueryResponse extends BaseResponse
{
    /**
     * 商户活动配置数据列表
     * @var MerchantActivityConfigData[]
     */
    public array $data = [];

    /**
     * 构造函数
     *
     * @param array|null $responseDict 响应字典
     */
    public function __construct(?array $responseDict = null)
    {
        parent::__construct($responseDict);
        
        if ($responseDict && isset($responseDict['data']) && is_array($responseDict['data'])) {
            foreach ($responseDict['data'] as $item) {
                $dataItem = new MerchantActivityConfigData();
                
                if (isset($item['act_id'])) $dataItem->setActId($item['act_id']);
                if (isset($item['merch_no'])) $dataItem->setMerchNo($item['merch_no']);
                if (isset($item['term_nos'])) $dataItem->setTermNos($item['term_nos']);
                if (isset($item['start_time'])) $dataItem->setStartTime($item['start_time']);
                if (isset($item['end_time'])) $dataItem->setEndTime($item['end_time']);
                if (isset($item['status'])) $dataItem->setStatus($item['status']);
                if (isset($item['create_time'])) $dataItem->setCreateTime($item['create_time']);
                if (isset($item['update_time'])) $dataItem->setUpdateTime($item['update_time']);
                
                $this->data[] = $dataItem;
            }
        }
    }

    /**
     * 将响应对象转换为数组
     *
     * @return array
     */
    public function toArray(): array
    {
        $result = parent::toArray();
        if (!empty($this->data)) {
            $result['data'] = array_map(function($item) {
                return $item->toArray();
            }, $this->data);
        }
        return $result;
    }
} 